<?php
import('ORG.Util.Function');

class ServiceAction extends CommonAction {
	
	public function _initialize(){
		parent::_initialize();
		$this->assign('li_selected','serivce');
		//titile
		$this->assign("global_title",		"售后服务_音伴尔官网");			
	}
	
	public function _empty(){
		$this->index();
	}
	
    public function index(){	
    	$ServiceModel			=	new ServiceModel();
    	$ArticleModel			=	new ArticleModel();
    	$service_article_list	=	$ServiceModel->get_service_article_list();
    	
    	$this->assign('service_article_list',	$service_article_list);
    	$this->assign('action',					'43');
		$this->assign('li_selected',			'serivce');	
    	$this->assign("menu_selected",			"shouhou");  //显示高亮菜单
		$this->display();
    }
    
    public function ajax_article(){    	
    	$article_id		=	intval($_POST['id']);    	
    	$sql			=	"SELECT article_id,title,cat_id,author,add_time,description,src from ybr_article WHERE article_id = '{$article_id}'";
    	$CommonModel	=	new CommonModel();
    	$info			=	$CommonModel->getRow($sql);
    	
		$file_path		=	"./Public/Upload/article/" . $info['src'];
		if(file_exists($file_path)){
			$content	=	file_get_contents($file_path);
		}    
		else{
			$content		=	"";
		}
		$info['content']	=	$content;
    	$this->ajaxReturn(1,$info,1);
    }
    
    /**
     * 使用教程
     * 
     */
    public function tutorial(){
    	//titile
		$this->assign("global_title",		"产品使用_音伴尔官网");	
    	$this->assign('li_selected','tutorial');
		//默认使用手册
		$cat_name = trim($_REQUEST['cat_name']);
		if(empty($cat_name)){
			$title = "使用手册";	
		}
		else{
			$title = $cat_name;
		}
		
		$ArticleModel	=	new ArticleModel();
		$article_list	=	$ArticleModel->get_list_byname($title);	
		
		$this->assign('article_list',$article_list);
		
		if($this->isAjax()){
			layout(false);
			$template	=	"Service:l_tutorial_list";
			$html		=	$this->fetch($template);
			$this->ajaxReturn(1,$html,1);
		}			
		
    	$this->assign("menu_selected",			"usage");  //显示高亮菜单	
    	$this->display();
    }
    
	public function item(){
		$article_id		=	intval($_GET['id']);
		if(empty($article_id)){
			$this->error("非法操作");
		}
		
		$ArticleModel		=	new ArticleModel();
		$article_info		=	$ArticleModel->article_info($article_id);
		//上一篇和下一篇文章的信息
		$related_articles	=	$ArticleModel->related_article($article_id);
		//赋值
		$this->assign('article_info',		$article_info);
		$this->assign('related_articles',	$related_articles);
		$this->display();
	}
	
	public function aboutus(){		
		//titile,keyword,
		$this->assign("global_title",		"关于音伴尔");
		
		$cat_name		=	"关于我们";
		$ArticleModel	=	new ArticleModel();		
		$artilce_list	=	$ArticleModel->get_list_byname($cat_name);		
		$service_article_list	=	array(
			array(
				'cat_name'		=> $cat_name,
				'article_list'	=> $artilce_list
			)
		);
		$this->assign("service_article_list",	$service_article_list);
		$this->assign('li_selected',			'aboutus');
    	$this->assign("menu_selected",			"about");  //显示高亮菜单
		$this->display("aboutus");
	}
	
	public function submit_feed(){		
		$this->ajaxReturn(1,1,1);
	}
	  
}
